package gatperdut.chato.core.interpreter.actions;

import gatperdut.chato.constants.CSConstantsCommandResult.CommandExecutionResult;
import gatperdut.chato.core.characters.BaseController;
import gatperdut.chato.core.interpreter.actions.generic.Action;
import gatperdut.chato.core.interpreter.grammar.comminfo.JunkInfo;
import gatperdut.chato.core.item.ItemController;

public class JunkAction extends Action {

    public JunkAction( JunkInfo info, BaseController entityController ) {
        super( info, entityController );
    }

    @Override
    public CommandExecutionResult perform() {
        checkForRunningCraft();

        if ( !checkUnindexedWord( getInfo().getWhat() ) ) {
            return CommandExecutionResult.OK;
        }
        ItemController ic = getEntityController().getInventoryController().getHeldItemController( getInfo().getWhat() );
        if ( ic == null ) {
            getEntityController().tx( "You don't seem to be holding that." );
            return CommandExecutionResult.OK;
        }

        ic.junk();

        getEntityController().tx( "You junk " + ic.getShortDesc() + "." );

        return CommandExecutionResult.OK;
    }

    @Override
    public JunkInfo getInfo() {
        return (JunkInfo) super.getInfo();
    }

    public boolean interruptsCrafting() {
        return false;
    };

}
